<template>
  <view class="qianqp-footer-tabbar" :class="theme">
    <view class="bgColor safe-bottom">
      <view v-for="(item, index) in tabbarList" :key="index" class="footer_item">
        <view v-if="item.raised" class="footer_nav_item posre" :class="item.pagePath == path ? 'activeTextColor' : 'textColor'" @click="tabbarA(item.pagePath)">
          <view class="raised_content">
            <image src="https://image.qqpyyds.com/mpAppImg/icon/videoActive_icon.png" class="images" v-if="theme === 'black'" />
            <i class="iconfont icon-add icon_box" v-else></i>
          </view>

          <view style="width:44rpx;height:52rpx;"></view>
          <text class="footer_nav_item_text">{{ item.text }}</text>
        </view>
        <view v-else class="footer_nav_item posre" :class="item.pagePath == path ? 'activeTextColor' : 'textColor'" @click.stop="tabbarA(item.pagePath)">
          <icon class="iconfont" :class="item.pagePath == path ? item.activeIcon : item.icon" style="font-size:44rpx;" />
          <text class="footer_nav_item_text">{{ item.text }}</text>
          <!-- 订单红点 -->
          <!-- <view class="redDot" v-if="index === 1 && (myPageInfo.deliverOrderCount || myPageInfo.sellerAfterSalesCount)"></view> -->
          <!-- 上下游红点 -->
           <view class="redDot" v-if="index === 3 && myPageInfo.distributionUnreadCount"></view>
          <!-- 我的红点 -->
          <view class="redDot" v-if="
            index === 4 &&
            (unreadcount||
            myPageInfo.sellerAfterSalesCount>0||
            myPageInfo.distributionUnreadCount>0||
            myPageInfo.fansUnreadCount>0||
            myPageInfo.goodsSquareCount>0||
            myPageInfo.canHelpSellCount>0||
            myPageInfo.userAfterSalesCount>0||
            myPageInfo.deliverOrderCount>0)"></view>
        </view>
      </view>
    </view>
    <ReleaseTypePage :show="showReleaseTypePage" @close="closeRelease"/>
  </view>
</template>
<script>

import ReleaseTypePage from "@/components/releaseTypePage/index.vue"

export default {
  name: 'Tabbar',
  props: {
    // 主题色
    theme: {
      type: String,
      default: 'white'
    },
  },
  components: {
    ReleaseTypePage
  },
  computed: {
    // IM消息未读数
    // unreadcount(){
    //   return this.$store.state.unreadcount
    // },
    // 其他红点未读数
    myPageInfo(){
      return this.$store.state.myPageInfo
    }
  },
  data() {
    return {
      path: '',
      tabbarList: [
        {
          pagePath: 'pages/index/index',
          text: '首页',
          icon: 'icon-main_home',
          activeIcon: 'icon-main_home_fill'
        },
        {
          pagePath: 'pages/store/index',
          text: '商城',
          icon: 'icon-shangchang',
          activeIcon: 'icon-shangchang_fill'
        },
        {
          pagePath: 'pagesA/release/issueEdit',
          text: '一键赚钱',
					raised: true
				},
        {
          pagePath: 'pages/stream/index',
          text: '上下游',
          icon: 'icon-shangxiayou',
          activeIcon: 'icon-shangxiayou_fill'
        },
        {
          pagePath: 'pages/my/index',
          text: '我的',
          icon: 'icon-main_user1',
          activeIcon: 'icon-main_user_fill'
        },
      ],
      showReleaseTypePage: false,
    }
  },
  async created() {
    const { route } = this.getRoute()
    this.path = route
    uni.hideTabBar(); // 默认隐藏原生tabbar,使用自定义底部
  },
  methods: {
    closeRelease () {
      this.showReleaseTypePage = false
    },
    tabbarA (url) {
      if(url === 'pagesA/release/issueEdit'){
        this.showReleaseTypePage = true
        // this.navigateTo({url: '/' + url})
      }else{
        this.switchTab({url: '/' + url})
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.qianqp-footer-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  box-shadow: 0 4rpx 24rpx rgba(150, 151, 153, 0.16);
  .footer_item {
    position: relative;
    flex: 1;
    width: 20%;
  }
  .footer_nav_item {
    height: 100rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .footer_nav_item_text {
    margin: 0 0 10rpx 0;
    font-size: 20rpx;
    line-height: 28rpx;
  }
  .posre{
    position: relative;
  }
  .redDot{
    width: 16rpx;
    height: 16rpx;
    border-radius: 16rpx;
    background: #E44435;
    position: absolute;
    left: 50%;
    transform: translateX(8rpx);
    top: 8rpx;
  }
  .raised_content {
    width: 80rpx;
    height: 80rpx;
    padding: 8rpx;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-20rpx);
    .images {
      width: 64rpx;
      height: 64rpx;
    }
    .icon_box {
      color: #E44435;
      font-size: 64rpx;
    }
  }
}

.white{
  .bgColor{
    width: 100%;
    display: flex;
    flex-direction: row;
    background: #fff;
    .raised_content{
      background: #fff;
    }
    .textColor {
      color: #969799;
    }
    .activeTextColor{
      color: $themeColor;
    }
  }
}

.black {
  .bgColor{
    width: 100%;
    display: flex;
    flex-direction: row;
    background: #000;
    .raised_content{
      background: #000;
    }
    .textColor {
      color: #969799;
    }
    .activeTextColor{
      color: $themeColor;
    }
  }
}
</style>